<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends CommonController {
	public function index(){
        $this->display();
    }
    public function header(){
    	$this->display('Public/header');
    }
    public function left(){
    	$this->display('Public/left');
    }
    public function indexc(){
    	$this->display('Public/indexcc');
    }

    // 修改密码
    public function editpass(){

        if(IS_POST){
            $uid = session('admin_id'); // 获取当前登录 id
            $re =M("admin_user") -> where("user_id = '$uid'") -> find();
            if($re['password'] == md5($_POST['oldpass'])){
                if($_POST['pass'] == $_POST['passc']){
                    $data['password'] = md5($_POST['pass']);
                    $save = M("admin_user") -> where("user_id = '$uid'") -> save($data); // 根据条件更新记录

                    if($save){
                      
                        $this->success('保存成功！');
                        die();
                    }else{
                        $this -> error("保存失败！");
                    }
                }else{
                    $this -> error("两次输入密码不一致，请重新输入！");
                }

            }else{
                $this -> error("输入的旧密码不正确，请重新输入！");
            }

        }


        $this -> display('Index/password');
    }

}